package com.yunhe.device.service.device;

import com.github.stuxuhai.jpinyin.PinyinException;
import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.exception.UniqueConstraintsException;
import com.yunhe.common.model.PageParam;
import com.yunhe.device.domain.device.EquipStatusCountVo;
import com.yunhe.device.domain.device.EquipTypeCountVo;
import com.yunhe.device.domain.device.Device;
import com.yunhe.device.model.device.*;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;

/**
 * @ClassName EquipmentService
 * @Description TODO
 * @Author HeTao
 * @Date 2021/7/15 17:42
 * @Version 1.0
 **/
public interface EquipmentService {

    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    Device createEquipmente(EquipmentBo equipmentBo) throws UniqueConstraintsException, PinyinException;

    Iterable<EquipmentVo> getEquipByQueryCondition(EquipmentQueryCondition equipmentQueryCondition);

    EquipmentBo getEquipById(Long id) throws ObjectNotFoundException;

    DeviceAnlogTypeVo getEquipAndAnlogTypeById(EquipAnlogTypeQueryCondition equipAnlogTypeQueryCondition) throws ObjectNotFoundException;

    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    void updateEquipById(EquipmentBo equipmentBo) throws UniqueConstraintsException, PinyinException;

    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    void updateEquipAndAnlogTypById(EquipmentBo equipmentBo) throws UniqueConstraintsException, ObjectNotFoundException, ArgumentErrorException, PinyinException;

    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    void deleteEquipById(Long id);

    EquipStatusCountVo getEquipCountByOwnedPark(List<Long> realStationIds);

    List<EquipTypeCountVo> getEquipTypeCountByOwnedPark(List<Long> realStationIds);

    List<Device> getEquipByOfficeId(List<Long> officeIds);

    Page<OfficeManageDeviceVO> getEquipInfoByOfficeId(Long officeId, PageParam pageParam);

    void downDeviceTemplate(Long equipTypeId, HttpServletResponse httpServletResponse) throws IOException, ArgumentErrorException;

    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    void importDevice(MultipartFile file) throws IOException, ArgumentErrorException, UniqueConstraintsException, PinyinException, ObjectNotFoundException;
}
